Linux / Windows Dual Boots and Daylight Savings Time

Posted on Sun 02 November 2014 in Tech Blog

You've got a laptop computer that dual-boots Slackware and Windows. When installing Slackware, you probably answered the question about whether or not the hardware clock is set to Coordinated Universal Time with "No", because Windows wants to keep the clock at local time. Today, you log into Linux first and immediately notice that your system time is an hour off. The reason for this is because you haven't run Windows since the change from Daylight Savings Time to Standard Time and the computer's hardware clock hasn't changed. Even if you are running the NTP daemon in Linux, the large time offset may be ignored as an error. So what do you do? You have two choices:

  • Shutdown and reboot into Windows, so it can set the hardware clock.
  • Run a couple of commands as root to set it from Linux.

I'm going to assume you would rather not reboot the computer. Before going any further, make sure you have the NTP package installed. On Slackware, you do this with ls /var/log/packages/ntp*. If you are using a different distro, use the appropriate package manager.

Run all of the following as root or using sudo to gain root privilege:

  1. If you use ntpd, stop the daemon.
    • Slackware: /etc/rc.d/rc.ntpd stop.
    • Sys V systems: use the service or systemctl commands.
  2. Run /usr/sbin/ntpdate pool.ntp.org.
  3. Run date to confirm the time is correct.
  4. If you use nptd, start it back up.
    • Slackware: /etc/rc.d/rc.ntdp start.
    • Sys V systems: use the commands in step 1-2.
  5. Set the hardware clock.
    • Slackare: /sbin/hwclock -w.
    • Sys V: ?

You are done!

Till next time,

Duane

Updated 20201206 DP: Improve steps text & add information for other Linux.